from bs4 import BeautifulSoup
import requests
'''
url = 'https://www.tripadvisor.cn/Attractions-g60763-Activities-New_York_City_New_York.html'
wb_data = requests.get(url)
soup = BeautifulSoup(wb_data.text, 'lxml')
titles = soup.select('div.listing_title > a[target="_blank"]')
imgs = soup.select('img[width="180"]')
cates = soup.select('div.p13n_reasoning_v2')

for title, img, cate in zip(titles, imgs, cates):
    data = {
        'title': title.get_text(),
        'img': img.get('src'),
        'cate': list(cate.stripped_strings)
    }
    print(data)
'''
#伪造登陆
headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36',
    'Cookie': 'TATravelInfo=V2*A.2*MG.-1*HP.2*FL.3*RS.1; TASSK=enc%3AANcesX9wcnmGY5sNsY%2FuAZUfsxrWF3mzBNc7TXFVoLzA5E%2BvGR2OUGZD9YX4lAviEVRiaFBWVpiBJzf09woGcNF5cPbQba%2B%2B2S0KB8lmRDd4cr37atzr4NgRnpPyIL1Fjg%3D%3D; TART=%1%enc%3AexCkE3tAS5I1TJarkxxUXR%2B%2B6XbolxofkcSt2WNtoaqntC7EYcNeIhpMZr%2FcWuFMJipDS%2B2%2Fvr0%3D; TAUnique=%1%enc%3Aplp4ZR4gFVU0l6kAa%2BPoZ%2BkLZZcY2WewqJotRk1%2BaXNQcF0be502LA%3D%3D; _ym_uid=1524015749680448233; _ga=GA1.2.1476990529.1524015753; _gid=GA1.2.627406682.1524015753; _smt_uid=5ad6a28e.4ee740c2; ki_r=; __gads=ID=4e67a7e390fcdf9a:T=1524017257:S=ALNI_Mbsb814dmpWsIIy3v9gBqAHZC_fGQ; TAPD=tripadvisor.cn; CommercePopunder=SuppressAll*1524018789869; ServerPool=B; CM=%1%HanaPersist%2C%2C-1%7CPremiumMobSess%2C%2C-1%7Ct4b-pc%2C%2C-1%7CSPHRSess%2C%2C-1%7CHanaSession%2C%2C-1%7CRestAds%2FRPers%2C%2C-1%7CRCPers%2C%2C-1%7CWShadeSeen%2C%2C-1%7CFtrPers%2C%2C-1%7CTheForkMCCPers%2C%2C-1%7CHomeASess%2C%2C-1%7CPremiumSURPers%2C%2C-1%7CPremiumMCSess%2C%2C-1%7CRestPartSess%2C%2C-1%7CCpmPopunder_1%2C1%2C1524104916%7CRestPremRSess%2C%2C-1%7CCCSess%2C%2C-1%7CPremRetPers%2C%2C-1%7CViatorMCPers%2C%2C-1%7Csesssticker%2C%2C-1%7Ct4b-sc%2C%2C-1%7CRestAdsPers%2C%2C-1%7CMC_IB_UPSELL_IB_LOGOS2%2C%2C-1%7Cb2bmcpers%2C%2C-1%7CMC_IB_UPSELL_IB_LOGOS%2C%2C-1%7CPremMCBtmSess%2C%2C-1%7CPremiumSURSess%2C%2C-1%7CLaFourchette+Banners%2C%2C-1%7Csess_rev%2C%2C-1%7Csessamex%2C%2C-1%7CPremiumRRSess%2C%2C-1%7CSaveFtrPers%2C%2C-1%7CSPMCSess%2C%2C-1%7CTheForkORSess%2C%2C-1%7CTheForkRRSess%2C%2C-1%7Cpers_rev%2C%2C-1%7CMetaFtrSess%2C%2C-1%7CRBAPers%2C%2C-1%7CWAR_RESTAURANT_FOOTER_PERSISTANT%2C%2C-1%7CFtrSess%2C%2C-1%7CRestAds%2FRSess%2C%2C-1%7CHomeAPers%2C%2C-1%7CPremiumMobPers%2C%2C-1%7CSPHRPers%2C%2C-1%7CRCSess%2C%2C-1%7CLaFourchette+MC+Banners%2C%2C-1%7CRestAdsCCSess%2C%2C-1%7CRestPartPers%2C%2C-1%7CRestPremRPers%2C%2C-1%7Csh%2C%2C-1%7Cpssamex%2C%2C-1%7CTheForkMCCSess%2C%2C-1%7CCCPers%2C%2C-1%7CWAR_RESTAURANT_FOOTER_SESSION%2C%2C-1%7Cb2bmcsess%2C%2C-1%7CSPMCPers%2C%2C-1%7CPremRetSess%2C%2C-1%7CViatorMCSess%2C%2C-1%7CPremiumMCPers%2C%2C-1%7CPremiumRRPers%2C%2C-1%7CRestAdsCCPers%2C%2C-1%7CTheForkORPers%2C%2C-1%7CPremMCBtmPers%2C%2C-1%7CTheForkRRPers%2C%2C-1%7CSaveFtrSess%2C%2C-1%7CRestAdsSess%2C%2C-1%7CRBASess%2C%2C-1%7CSPORPers%2C%2C-1%7Cperssticker%2C%2C-1%7CMetaFtrPers%2C%2C-1%7C; TAReturnTo=%1%%2FAttraction_Review-g60763-d8072300-Reviews-One_World_Observatory-New_York_City_New_York.html; roybatty=TNI1625!AB8RpPcgGSR7IuVIj%2FyDQETWXBI%2BtU%2Fhk7YfFtroVwr4vPnwfxMlyY3AJL4O8EWgyVh%2FuKHSvaTYQeyl4DJWYuKFMmCUObTdjikLC8bg%2FFMdeWSRcYH%2BinaKaDndDAJPeh9KshECHNehS5RGR5zuYEsCXy93dDP6AR6yjrW2XVmt%2C1; ki_t=1524015760044%3B1524104089523%3B1524104089523%3B2%3B12; SecureLogin2=3.4%3AALGiKbUsj6A5WHrmgf7s2IIh%2Fe44enHWSqxuRojsFEPlFTtHLzo1ciP9CvSuLTJtdVtwH4ME9Kifv6NBGWrfRu9qMMISoeaMkQRH51gUGJyADz6HQhhazv4eLSoNA4z9vAtHr%2Fjq27WfXbhTFAlCo%2BiLTIS5LarlMAwq4oJCi99KLGAo9YYrmRKoVk9ZTDZGDZvMreKuEqy6zwxk%2B8Y4vmY%3D; TAAuth3=3%3A3be291d9cb23c60e68fd6b7b0fa13704%3AABSprBLoOxFwmZ%2Fbrfjg75tRDCiKzl0D8186FZWo7M4IoLgt67731Go9hKsV43HOtBlC16ne%2B1DGJ%2F6xam4W9xkKcw%2BX4uZsCWYb5Rr%2FGbsryvJBNkZlmDicyJc8i0zFy1sWYDdGiBXu2P0cQXZrg76G7pLG3IsXXfQ0%2FItWD%2FAMHcQ9rY6LN7pDgpRSEfIuJw%3D%3D; TASession=%1%V2ID.CB4C0D791FB65D7ABCB6848B8E5B63F4*SQ.28*LP.%2FAttractions-g60763-Activities-New_York_City_New_York%5C.html*PR.39766%7C*LS.MetaPlacementAjax*GR.81*TCPAR.34*TBR.45*EXEX.16*ABTR.56*PHTB.75*FS.9*CPU.48*HS.recommended*ES.popularity*AS.popularity*DS.5*SAS.popularity*FPS.oldFirst*TS.D934ADCDCF1F243DE07C016194AAB9D8*LF.zhCN*FA.1*DF.0*MS.-1*RMS.-1*FLO.60763*TRA.true*LD.8072300; TAUD=LA-1524039603246-1*RDD-1-2018_04_18*LG-64713737-2.1.F.*LD-64713738-.....'

}

url_saves = 'https://www.tripadvisor.cn/Saves/1111870'
wb_data = requests.get(url_saves, headers=headers)
soup = BeautifulSoup(wb_data.text, 'lxml')
titles = soup.select('trip-item-collection-container > div > div > div.saves-location-details.ui_media > div.media-content > div > a.')
print(titles)
